package com.exp.bookhouse.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.exp.bookhouse.swagger.IgnoreSwaggerParameter;
import com.exp.bookhouse.util.AmountUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@ApiModel("订单实体类Order")
@TableName("tb_order")
public class Order implements Serializable {

    @ApiModelProperty(value = "订单id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "订单号")
    private String orderNum;    //订单号

    @ApiModelProperty(value = "买家姓名")
    private String userName;    //买家姓名

    @ApiModelProperty(value = "买家电话")
    private String userPhone;   //买家电话

    @ApiModelProperty(value = "买家地址")
    private String userAddress;     //买家地址

    @ApiModelProperty(value = "买家微信openid")
    private String userOpenid;  //买家微信openid

    @ApiModelProperty(value = "订单总额")
    private Long amount;        //订单总额


    @TableField(exist = false)
    private String amountStr;

    @ApiModelProperty(value = "订单状态, 0:未支付  1:已支付  2:已取消")
    private Integer orderStatus;    //订单状态, 0:未支付  1:已支付  2:已取消

    @TableField(exist = false)
    private String orderStatusStr;

    @ApiModelProperty(value = "支付状态  0：支付宝 1：微信 2：其他")
    private Integer payStatus;      //支付状态  0：支付宝 1：微信 2：其他

    @TableField(exist = false)
    private String payStatusStr;

    @ApiModelProperty(value = "订单创建时间",hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;    //创建时间

    @ApiModelProperty(value = "订单修改时间",hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;    //更新时间

    @ApiModelProperty(value = "订单细节列表")
    @IgnoreSwaggerParameter     //不递归展开
    @TableField(exist = false)
    private List<OrderDetail> orderDetails;     //订单细节


    public Order() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getUserOpenid() {
        return userOpenid;
    }

    public void setUserOpenid(String userOpenid) {
        this.userOpenid = userOpenid;
    }

    public String getUserAddress() {
        return userAddress;
    }

    public void setUserAddress(String userAddress) {
        this.userAddress = userAddress;
    }

    public Long getAmount() {
        return amount;
    }

    public void setAmount(Long amount) {
        String str = "";
        if(amount != null){
            str = AmountUtil.changeF2Y(amount);
        }
        this.amountStr = str;
        this.amount = amount;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        //订单状态, 0:未支付  1:已支付  2:已取消
        String str = "";
        if(orderStatus != null){
            if(orderStatus == 0) {
                str = "未支付";
            }else if(orderStatus == 1){
                str = "已支付";
            }else if(orderStatus == 2){
                str = "已取消";
            }
        }
        this.orderStatusStr = str;
        this.orderStatus = orderStatus;
    }

    public Integer getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(Integer payStatus) {
        //支付状态  0：支付宝 1：微信 2：其他
        String str = "";
        if(payStatus != null){
            if(payStatus == 0){
                str = "支付宝";
            }else if (payStatus == 1){
                str = "微信";
            }else if(payStatus == 2){
                str = "其他";
            }
        }
        this.payStatusStr = str;
        this.payStatus = payStatus;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<OrderDetail> getOrderDetails() {
        return orderDetails;
    }

    public void setOrderDetails(List<OrderDetail> orderDetails) {
        this.orderDetails = orderDetails;
    }


    public String getAmountStr() {
        return amountStr;
    }

    public void setAmountStr(String amountStr) {
        this.amountStr = amountStr;
    }

    public String getOrderStatusStr() {
        return orderStatusStr;
    }

    public void setOrderStatusStr(String orderStatusStr) {
        this.orderStatusStr = orderStatusStr;
    }

    public String getPayStatusStr() {
        return payStatusStr;
    }

    public void setPayStatusStr(String payStatusStr) {
        this.payStatusStr = payStatusStr;
    }

    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", orderNum='" + orderNum + '\'' +
                ", userName='" + userName + '\'' +
                ", userPhone='" + userPhone + '\'' +
                ", userOpenid='" + userOpenid + '\'' +
                ", userAddress='" + userAddress + '\'' +
                ", amount=" + amount +
                ", orderStatus=" + orderStatus +
                ", payStatus=" + payStatus +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", orderDetails=" + orderDetails +
                '}';
    }
}
